package com.naiterui.ehp.bs.b2c.product.controller.inner;

import cn.hutool.core.date.DateUtil;
import com.naiterui.ehp.bp.support.exception.PublicService;
import com.naiterui.ehp.bp.support.exception.ResponseVO;
import com.naiterui.ehp.bs.b2c.product.service.IB2cSuperviseService;
import com.naiterui.ehp.bs.b2c.product.vo.SuperviseSkuVO;
import com.naiterui.ehp.bs.b2c.product.vo.TianjinSuperviseProductVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

/**
 * <pre>
 * 提供监管对接信息获取内部接口
 * </pre>
 *
 * @author fangguanhong
 * @date 2021/1/13 下午1:47
 * @since 1.0.0
 */
@Slf4j
@RequestMapping("b2c/inner/supervise")
@RestController
public class InnerB2cSuperviseController {

    @Autowired
    private IB2cSuperviseService superviseService;

    @PostMapping("recom/product")
    public ResponseVO<List<SuperviseSkuVO>> recomProduct(@RequestBody List<Long> skuIds) {
        log.info("获取监管处方商品信息， skuIds {}", skuIds);
        return PublicService.returnResponseVO(superviseService.recomProduct(skuIds));
    }

    /**
     * 天津监管商品信息
     *
     * @param startDate
     * @param endDate
     */
    @GetMapping("tianjin/product")
    public ResponseVO<List<TianjinSuperviseProductVO>> tianjinProduct(String startDate, String endDate){
        log.info("获取天津监管商品信息 startDate:{}, endDate:{}", startDate, endDate);
        Date start = DateUtil.parseDateTime(startDate).toJdkDate();
        Date end = DateUtil.parseDateTime(endDate).toJdkDate();
        return PublicService.returnResponseVO(superviseService.tianjinProduct(start, end));
    }
}
